<?php
$data = $this->data;
$images = $data->hinhAnh;
$images = explode("|", $images);
?>
<div class="admin-content table-reponsive">
	<table class="table table-bordered" style="width: 80%; max-width: 600px; margin:0px auto; margin-top:12px;">
      <tbody>
        <tr>
          <td>Mã sản phẩm</td>
          <td><?php echo $data->maHang ; ?></td>
        </tr>
        <tr>
          <td>Số lượng</td>
          <td><?php echo $data->soLuong ; ?></td>
        </tr>
        <tr>
          <td>Ngày nhập</td>
          <td><?php echo $data->ngayNhap ; ?></td>
        </tr>
        <tr>
          <td>Đơn giá</td>
          <td><?php echo $data->gia ; ?></td>
        </tr>
        <tr>
          <td>Loại hàng</td>
          <td><?php echo $data->loaiHang ; ?></td>
        </tr>
        <tr>
          <td>Mô tả</td>
          <td><?php echo $data->moTa ; ?></td>
        </tr>
        <tr>
          <td rowspan="<?php echo count($images)-1;?>">Hình ảnh</td>
          <td>
          	<?php echo '<img height="auto" width="300px" src="/files/'.$data->loaiHang.'/'.$data->maHang.'/'.$images[0].'">'; ?>
          </td>
        </tr>
        <?php
        	if(count($images)>2){
        		for($i = 1; $i < count($images) - 1; $i++){
        			echo '<tr>';
        			echo '<td>';
        			echo '<img height="auto" width="300px" src="/files/'.$data->loaiHang.'/'.$data->maHang.'/'.$images[$i].'" id="myimg" onerror="imgError(this)">';
        			echo '</td>';
        			echo '</tr>';
        		}
        	}
        ?>
        <tr>
          <td style="border-right:none;"></td>
        <td style="border-left:none;">
          <span>
            <a class="btn btn-primary" href="/admin/manage/edit/id/<?php echo $data->id; ?>">Sửa</a> &nbsp; 
            <a class="btn btn-danger" href="/admin/manage/delete/id/<?php echo $data->id; ?>">Xóa</a> &nbsp; 
            <a class="btn btn-success" href="/admin/bill/create-bill/id/<?php echo $data->id; ?>">Tạo hóa đơn</a>
          </span>
        </td>
        </tr>
      </tbody>
    </table>
</div>
